<?php
error_reporting(E_ALL & ~E_STRICT & ~E_NOTICE);
session_start();

class Session
{

    private static $islogin = false;

    public  static function set($key, $role)
    {
        $_SESSION[$key] = $role;
    }

    public static function get($key)
    {
        return isset($_SESSION[$key]) ? $_SESSION[$key] : '';
    }

    public static function dologout()
    {

        if (isset($_SESSION)) {
            foreach ($_SESSION as $key => $value) {
                unset($_SESSION[$key]);
            }
            session_destroy();
            header("Location: ./");
            exit;
        }

    }

    public static function checkLogin()
    {
        if (!isset($_SESSION['sessionToken'])) {
            header('Location: ./index.php');
            exit;
        }
    }

    public static function tokenExist()
    {
        return isset($_SESSION['sessionToken']);
    }
}
